package com.spic.business.preset_point.controller;

import java.util.List;
import java.io.IOException;
import javax.servlet.http.HttpServletResponse;

import com.spic.business.preset_point.domain.PresetsPosition;
import com.spic.business.preset_point.service.IPresetsPositionService;
import com.spic.common.core.utils.poi.ExcelUtil;
import com.spic.common.core.web.controller.BaseController;
import com.spic.common.core.web.domain.AjaxResult;
import com.spic.common.log.annotation.Log;
import com.spic.common.log.enums.BusinessType;
import com.spic.common.security.annotation.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 摄像头资源预置点位置信息Controller
 *
 * @author spic
 * @date 2022-03-25
 */
@RestController
@RequestMapping("/presets_position")
public class PresetsPositionController extends BaseController
{
    @Autowired
    private IPresetsPositionService presetsPositionService;

    /**
     * 查询摄像头资源预置点位置信息列表
     */
    @GetMapping("/list")
    public AjaxResult list(PresetsPosition presetsPosition)
    {
        List<PresetsPosition> list = presetsPositionService.selectPresetsPositionList(presetsPosition);
        return AjaxResult.success(list);
    }

    /**
     * 导出摄像头资源预置点位置信息列表
     */
    @PreAuthorize(hasPermi = "business:presets_position:export")
    @Log(title = "摄像头资源预置点位置信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, PresetsPosition presetsPosition) throws IOException
    {
        List<PresetsPosition> list = presetsPositionService.selectPresetsPositionList(presetsPosition);
        ExcelUtil<PresetsPosition> util = new ExcelUtil<PresetsPosition>(PresetsPosition.class);
        util.exportExcel(response, list, "摄像头资源预置点位置信息数据");
    }

    /**
     * 获取摄像头资源预置点位置信息详细信息
     */
    @PreAuthorize(hasPermi = "business:presets_position:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id)
    {
        return AjaxResult.success(presetsPositionService.selectPresetsPositionById(id));
    }

    /**
     * 新增摄像头资源预置点位置信息
     */
    @Log(title = "摄像头资源预置点位置信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody PresetsPosition presetsPosition)
    {
        return toAjax(presetsPositionService.insertPresetsPosition(presetsPosition));
    }

    /**
     * 修改摄像头资源预置点位置信息
     */
    @Log(title = "摄像头资源预置点位置信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody PresetsPosition presetsPosition)
    {
        return toAjax(presetsPositionService.updatePresetsPosition(presetsPosition));
    }

    /**
     * 删除摄像头资源预置点位置信息
     */
    @PreAuthorize(hasPermi = "business:presets_position:remove")
    @Log(title = "摄像头资源预置点位置信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids)
    {
        return toAjax(presetsPositionService.deletePresetsPositionByIds(ids));
    }
}
